<?php
  include("./dbconn.php");

  $user = $_GET["user"];
  $pw = $_GET["pw"];

   $sql = "select * from user where user='$user'";

   $result = $conn->query($sql);


   if ($result->num_rows > 0){
      $row = mysqli_fetch_assoc($result);
      //用户名和密码都匹配
      if ($pw == $row["pw"]){
          $data["code"] = 0;
          $data["msg"] = '登录成功';
      }else{
          $data["code"] = 1;
          $data["msg"] = '密码错误';
      }
   }else{
      //用户名不存在
         $data["code"] = 2;
          $data["msg"] = '用户名不存在';
   }
   echo json_encode($data);
?>